{% load i18n %}
{% load inventree_extras %}

{% settings_value 'BARCODE_ENABLE' as barcodes %}

{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}
    {% authorized_owners location.owner as owners %}
{% endif %}

<div id='{{ prefix }}button-toolbar'>
    <div class='button-toolbar container-fluid' style='float: right;'>
        <div class='btn-group' role='group'>
            {% if barcodes %}
            <!-- Barcode actions menu -->
            <div class='btn-group' role='group'>
                <button id='stock-barcode-options' class='btn btn-primary dropdown-toggle' type='button' data-bs-toggle='dropdown' title='{% trans "Barcode Actions" %}'>
                    <span class='fas fa-qrcode'></span> <span class='caret'></span>
                </button>
                <ul class='dropdown-menu'>
                    <li><a class='dropdown-item' href='#' id='multi-item-barcode-scan-into-location' title='{% trans "Scan to Location" %}'><span class='fas fa-sitemap'></span> {% trans "Scan to Location" %}</a></li>
                </ul>
            </div>
            {% endif %}
            {% if not read_only %}
            {% if roles.stock.change or roles.stock.delete %}
            <div class="btn-group" role="group">
                <button id='stock-options' class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" title='{% trans "Stock Options" %}'>
                    <span class='fas fa-boxes'></span> <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    {% if roles.stock.change %}
                    <li><a class='dropdown-item' href="#" id='multi-item-add' title='{% trans "Add to selected stock items" %}'><span class='fas fa-plus-circle icon-green'></span> {% trans "Add stock" %}</a></li>
                    <li><a class='dropdown-item' href="#" id='multi-item-remove' title='{% trans "Remove from selected stock items" %}'><span class='fas fa-minus-circle icon-red'></span> {% trans "Remove stock" %}</a></li>
                    <li><a class='dropdown-item' href="#" id='multi-item-stocktake' title='{% trans "Stocktake selected stock items" %}'><span class='fas fa-check-circle icon-green'></span> {% trans "Count stock" %}</a></li>
                    <li><a class='dropdown-item' href='#' id='multi-item-move' title='{% trans "Move selected stock items" %}'><span class='fas fa-exchange-alt icon-blue'></span> {% trans "Transfer stock" %}</a></li>
                    <li><a class='dropdown-item' href='#' id='multi-item-merge' title='{% trans "Merge selected stock items" %}'><span class='fas fa-object-group'></span> {% trans "Merge stock" %}</a></li>
                    <li><a class='dropdown-item' href='#' id='multi-item-order' title='{% trans "Order selected items" %}'><span class='fas fa-shopping-cart'></span> {% trans "Order stock" %}</a></li>
                    <li><a class='dropdown-item' href='#' id='multi-item-assign' title='{% trans "Assign to customer" %}'><span class='fas fa-user-tie'></span> {% trans "Assign to customer" %}</a></li>
                    <li><a class='dropdown-item' href='#' id='multi-item-set-status' title='{% trans "Change status" %}'><span class='fas fa-exclamation-circle'></span> {% trans "Change stock status" %}</a></li>
                    {% endif %}
                    {% if roles.stock.delete %}
                    <li><a class='dropdown-item' href='#' id='multi-item-delete' title='{% trans "Delete selected items" %}'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete stock" %}</a></li>
                    {% endif %}
                    </ul>
                </div>
            {% endif %}
            {% endif %}
            {% include "filter_list.html" with id="stock" %}
        </div>
    </div>
</div>

<table class='table table-striped table-condensed' data-toolbar='#{{ prefix }}button-toolbar' id='{{ prefix }}stock-table'>
</table>
